from django.db import models

# Create your models here.
# 用户模型
class Users(models.Model):
	username = models.CharField(max_length=50)
	password = models.CharField(max_length=100)
	phone = models.CharField(max_length=11)
	sex = models.CharField(max_length=1,null=True)
	age = models.CharField(max_length=100,null=True)
	head_url = models.CharField(max_length=100,null=True)
	status = models.IntegerField(default=0)
	addtime=models.DateTimeField(auto_now_add=True)

class Cates(models.Model):
	name = models.CharField(max_length=50)
	upid = models.IntegerField()
	paths = models.CharField(max_length=50)

class Goods(models.Model):
    
    title = models.CharField(max_length=100)
    g_url = models.CharField(max_length=200)
    price = models.IntegerField()
    ordernum = models.IntegerField()
    ginfo = models.TextField()

    status = models.IntegerField(default=0)
    clicknum = models.IntegerField(default=0)
    addtime = models.DateTimeField(auto_now_add=True)

    cateid=models.ForeignKey(to="Cates",to_field="id")

class Car(models.Model):
	gid = models.ForeignKey(to="Goods",to_field="id")
	num = models.IntegerField()
	uid = models.ForeignKey(to="Users",to_field="id")
# 用户的收货人地址
class Address(models.Model):
	name = models.CharField(max_length=100)
	phone = models.CharField(max_length=100)
	sheng = models.CharField(max_length=100)
	shi = models.CharField(max_length=100)
	xian = models.CharField(max_length=100)
	addinfo = models.CharField(max_length=255)

	uid = models.ForeignKey(to="Users",to_field="id")

	isselect = models.IntegerField(default=0)

class Citys(models.Model):
	name = models.CharField(max_length=100)
	level = models.IntegerField()
	upid = models.IntegerField()

	class Meta():
		db_table='citys'

# 订单
class Order(models.Model):
	uid = models.ForeignKey(to="Users",to_field="id")
	phone = models.CharField(max_length=100)
	name = models.CharField(max_length=100)
	addinfo = models.CharField(max_length=255)
	total = models.IntegerField()

	wl = models.IntegerField()

	pay = models.IntegerField()

	status = models.IntegerField(default=0)

	createtime = models.DateTimeField(auto_now_add=True)

	paytime = models.DateTimeField(null=True)

class Orderinfo(models.Model):
	orderid = models.ForeignKey(to="Order",to_field="id")
	gid = models.ForeignKey(to="Goods",to_field="id")
	num = models.IntegerField()
	price = models.IntegerField()



















